//大数相加

//BigInt 大数

//
var a = 8456987456111111111
var b = 8748451111111111

var c =BigInt(a)+BigInt(b)//方法1
console.log(c)
// console.log(typeof c)

console.log(' '+a)
console.log(' '+b)

//方法2
function myBigInt(a,b) {
    let n1 = a.toString().split('').reverse()
    let n2 = b.toString().split('').reverse()
    // console.log(n1,n2)
    let maxLength = Math.max(n1.length,n2.length)
    let res = []
    let v = 0
    for(let i=0;i<maxLength;i++){
        let a = Number(n1[i]) || 0
        let b = Number(n2[i]) || 0
        let item = a + b + v
        if(item >= 10){
            item = item % 10
            v = 1
        }else{
            v = 0
        }
        res.push(item)
    }
    if(v) res.push(v)
    return res.reverse().join('')

}
console.log(myBigInt(a,b))